package com.cz.basetool.ui_work.util.et_bind;


import android.util.Pair;

import com.cz.basetool.R;
import com.cz.basetool.ui_work.util.txt.CZ_TextUtil;
import com.cz.basetool.ui_work.util.txt.RegularUtil;
import com.cz.basetool.ui_work.util.et_bind.base.BaseEditTextValidator;

/**
 * Created by 陈章 on 2017/4/12 0012.
 * func:
 * 电话号校验器
 */
public class TelePhoneValidator extends BaseEditTextValidator {
    public TelePhoneValidator() {
    }

    public TelePhoneValidator(OnValidatorResultObserver validatorResultObserver) {
        super(validatorResultObserver);
    }

    @Override
    public Pair validate(String phone) {
        //电话号可为空
        if(CZ_TextUtil.is_null_or_empty(phone)){
            return getRightPair();
        }

        //电话号不合法
        if(!RegularUtil.isTelePhoneNumber(phone)){
            return getErrorPair(mContext.getString(R.string.warn_input_telephone_illegal));
        }
        return getRightPair();
    }
}
